﻿using System;

namespace syno_exec.csm
{
    using ExcelConfig;
    using ExcelConfig.Config;
    using ExcelConfig.StoreAPI;
    internal class cgsys
    {
        internal const string cfg_path = "./config";
        internal static string config_zone = string.Empty;
        internal static AppConfigFile config;
        static cgsys()
        {
            if (!Directory.Exists(cfg_path)) Directory.CreateDirectory(cfg_path);
            config_zone = AppConfig.Text("配置域");
            auto_download("activebak-sz-tofco", "app.config");
            config = new AppConfigFile(cfg_path);
        }
        internal static string read_cgpath(string name)
        {
            if (!name.EndsWith(".xlsx")) name += ".xlsx";
            return Path.Combine(cfg_path, name);
        }
        internal static void auto_download(string name, string outfilename)
        {
            if (!File.Exists(read_cgpath(outfilename))) ConfigStoreAPI.DownloadToFile(config_zone, name, read_cgpath(outfilename)).Wait();
        }
    }
}
